import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


// 解决重复跳转当前路径
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/home.vue'),
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: () => import('../components/homeTopic/welcome.vue')
      },
      {
        path: '/pressList',
        name: 'pressList',
        component: () => import('../components/homeTopic/pressList.vue')
      }
    ]
  },
  {
    path: '/pressDetail/:id',
    name: 'pressDetail',
    component: () => import('../components/homeTopic/pressDetail.vue')
  },

  {
    path: '/publishPress',
    name: 'publishPress',
    component: () => import('../views/publish_press.vue')
  },
  {
    path: '/blog',
    name: 'blog',
    component: () => import('../views/blog.vue')
  },
  {
    path: '/photo',
    name: 'photo',
    component: () => import('../views/photo.vue')
  },
  {
    path: '/message',
    name: 'message',
    component: () => import('../views/message.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue')
  }
]


const router = new VueRouter({
  routes,
  mode: 'history'
})



export default router
